{layout name="formlayout" /}

<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px">

    <div class="layui-form-item">
        <label class="layui-form-label">位置</label>
        <div class="layui-input-block">
            <select name="remarks" lay-filter="required">
                <option value="主页" selected="">主页</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
        <div class="layui-input-inline">
            <input type="text" id="phy" name="phy" value="{$item.phy|default=''}" lay-verify="required"
                   placeholder="请上传图片"
                   autocomplete="off" class="layui-input">
            <div class="layui-upload-list">
                <img class="layui-upload-img" id="demo1" src="{$item.phy|default=''}">
                <p id="demoText"></p>
            </div>
        </div>
        <button style="float: left;" type="button" class="layui-btn" id="layuiadmin-upload-slideshow">上传图片</button>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" value="{$item.id}">
        <input type="button" lay-submit lay-filter="zbc-slideshow-submit" id="zbc-slideshow-submit" value="确认">
    </div>

</div>
<!-- 配置文件 -->
<script type="text/javascript" src="/ue/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/ue/ueditor.all.js"></script>
<script>
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['laydate', 'index', 'form', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            , laydate = layui.laydate
            , upload = layui.upload;

        upload.render({
            elem: '#layuiadmin-upload-slideshow'
            , url: '/admin/upload/image?type=slideshow'
            , accept: 'images'
            , method: 'post'
            , acceptMime: 'image/*'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //$(this.item).prev("div").children("input").val(res.data.src)
                //console.log(res);
                if (!res.data)
                    return layer.msg('上传失败');
                else {
                    $("#phy").val(res.data.src);
                }
            }
        });
    });
</script>